package sctu.edu.java.year2016.team01.lishuai.day20160521.chapter4_2;

/**
 * Created by 李帅 on 2016/5/21.
 * 利用for循环输出一个菱形
 */
import java.util.Scanner;
public class LingXing1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("行数为：");
        int row = scan.nextInt();
        int i,j,k;
        for(i=1;i<=row;i++)    //控制行
        {
            for(j=1;j<=row-i;j++)   //控制空格
                System.out.print(" ");
            for(k=0;k<2*i-1;k++){
                if(k==0||k==2*i-2)
                {
                    System.out.print("*");
                }
                else
                {
                    System.out.print(" ");
                }
            }

            System.out.println();
        }
        for(i=row-1;i>0;i--)
        {
            for(j=0;j<row-i;j++)
                System.out.print(" ");
            for(k=0;k<2*i-1;k++)
            {
                if(k==0||k==2*i-2)
                {
                    System.out.print("*");
                }
                else
                {
                    System.out.print(" ");
                }
            }
            System.out.println();
        }

    }

}
